<template>
	<view class="goods_detail">
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(i,index) in swiperdetail" :key="index">
				<image src="../../static/dog.png" ></image>
			</swiper-item>			
		</swiper>
		<view class="box1">
			<view class="price">
				<text>￥{{detailInfo.sell_price}}</text>
				<text>￥{{detailInfo.market_price}}</text>
				
			</view>
			<view class="goodsName">
				{{detailInfo.title}}
			</view>
		</view>
		<view class="line">
		</view>
		<view class="box2">
			<view class="">
				货号:&nbsp {{detailInfo.goods_no}}
			</view>
			<view class="">
				库存:&nbsp {{detailInfo.stock_quantity}}
			</view>
		</view>
		<view class="line">
		</view>
		<view class="box3">
			<view class="tit">
				详情介绍
			</view>
			<view class="content">
			<rich-text :nodes="content.content"></rich-text>
			</view>
		</view>
		<view class="goodsNav">
			<uni-goods-nav :fill="true"  :options="options" :buttonGroup="buttonGroup"  @click="onClick" @buttonClick="buttonClick" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				swiperdetail:[],
				detailInfo:{},
				content:'',
				 options: [
					 {
				            icon: 'headphones',
				            text: '勇敢牛牛'
				    },
					{
				            icon: 'shop',
				            text: '店铺',
				            info: '',
				            infoBackgroundColor:'#007aff',
				            infoColor:"red"
				    },
					{
				            icon: 'cart',
				            text: '购物车',
				            info: 99
				    },
					],
		buttonGroup: [{
						    text: '加入购物车',
						    backgroundColor: '#ff0000',
						    color: '#fff'
						},
						{
						    text: '迅速购买',
						    backgroundColor: '#ffa200',
						    color: '#fff'
						}
					]
			}
		},
		methods: {
			async getSwiperDetail(){
				let res= await this.$myRequest({
					url:`/api/getthumimages/${this.id}`
				})
				this.swiperdetail=res.data.message
			},
			async getDetaiInfo(){
				let res= await this.$myRequest({
					url:`/api/goods/getinfo/${this.id}`,
					method:'get'
				})
				this.detailInfo=res.data.message[0]
			},
			async getDesContent(){
				let res= await this.$myRequest({
					url:`/api/goods/getdesc/${this.id}`
				})
				this.content=res.data.message[0]
				
			},
			onClick (e) {
			        uni.showToast({
			          title: `点击${e.content.text}`,
			          icon: 'none'
			        })
			      },
			buttonClick (e) {
			        console.log(e)
			        this.options[2].info++
			      }
			 
		},
		onLoad(options) {
			this.id=options.id
			this.getSwiperDetail()
			this.getDetaiInfo()
			this.getDesContent()
		}
	}
</script>

<style lang="less">
	.goods_detail{
		swiper{
			height: 700rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.box1{
			padding: 20rpx;
			.price{
				font-size: 35rpx;
				color: #e50b30;
				line-height: 80rpx;
				
				text:nth-child(2){
					color: #ccc;
					font-size: 28rpx;
					text-decoration: line-through;
					margin-left: 30rpx;
				}
			}
			.goodsName{
				font-size: 32rpx;
				line-height: 60rpx;
			}
			
		}
		.box2{
			padding: 0 10px;
			font-size: 32rpx;
			line-height: 60rpx;
			
		}
		.box3{
			padding-bottom:50rpx ;
			.tit{
				font-size: 30rpx;
				padding-left:12px;
				border-bottom: 1px solid #ccc;
				line-height: 70rpx;
			}
			.content{
				padding: 10px;
				line-height: 50rpx;
				color: #333;
				
			}
		}
		.line{
			height: 10rpx;
			width: 750rpx;
			background: #eee;
		}
		.goodsNav{
			position: fixed;
			bottom: 0;
			width: 100%;
		}
	}
</style>
